package com.dingli.admin.service.impl;

import com.dingli.admin.service.LoginUser;
import com.dingli.framework.entity.User;
import com.dingli.framework.mapper.UserMapper;
import com.dingli.framework.util.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LoginUserImpl implements LoginUser {
    @Autowired
    private UserMapper userMapper;

    @Override
    public Response<User> getUser(String name, String password) {
        List<User> user = userMapper.getUser(name);
        if (user.size() == 0 && user.get(0).getPassword() != password) {
            return new Response(500, "登录错误");
        }
        return new Response(200, "登录成功", user);
    }
}
